$(function () {
    vm.getMessage();
});

var vm = new Vue({
    el: '#rrapp',
    data: {
        message: {},
        messageList: {}
    },

    methods: {
        getMessage: function () {
            $.get(baseURL + "ede/message/getAllList", function (r) {
                vm.messageList = r.messageList;
            });
        },
        save: function () {
            $('#save').button('loading').delay(1000).queue(function () {
                var message = $("#message").val();
                if (message == '') {
                    alert("请填写发表内容！");
                    $('#save').button('reset');
                    $('#save').dequeue();
                    return;
                }
                $.ajax({
                    type: "POST",
                    url: baseURL + "ede/message/save",
                    contentType: "application/json",
                    data: JSON.stringify(vm.message),
                    success: function (r) {
                        if (r.code === 0) {
                            layer.msg("发表成功", {icon: 1});
                            $('#save').button('reset');
                            $('#save').dequeue();
                            vm.message = {};
                            vm.getMessage();
                        } else {
                            layer.alert(r.msg);
                            $('#save').button('reset');
                            $('#save').dequeue();
                        }
                    }
                });
            });
        }


    }
});